package day52.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private MyInterceptor myInterceptor;

    // 这个方法用来注册拦截器，我们自己写好的拦截器需要通过这里添加注册才能生效
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor)
                //拦截所有
                .addPathPatterns("/**")
                //放开登陆页面
                .excludePathPatterns("/login/**")
                //放开图片上传业面
                .excludePathPatterns("/fast_dfs/**")
                //放开获取验证码业面
                .excludePathPatterns("/verify_code/**")
                //放开店铺入驻业面
                .excludePathPatterns("/shop/settle")
                //放开注册界面
                .excludePathPatterns("/registe/**")
                //放行重置密码界面
                .excludePathPatterns("/reset/**");
    }
}
